<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="description" content="">
		<meta name="author" content="Mosaddek">
		<meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
		<link rel="shortcut icon" href="img/favicon.html">

		<title>登录</title>

		<!-- Bootstrap core CSS -->
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<link href="css/bootstrap-reset.css" rel="stylesheet">
		<!--external css-->
		<link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
		<!-- Custom styles for this template -->
		<link href="css/style.css" rel="stylesheet">
		<link href="css/style-responsive.css" rel="stylesheet" />
		<style>
			.m-b {
			  margin-bottom: 15px;
			}
			.full-width {
			  width: 100% !important;
			}
		</style>
		<!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
		<!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->
	</head>

	<body class="login-body">

		<div class="container">

			<form class="form-signin" action="paramedics-userinfo.html">
				<h2 class="form-signin-heading">登录</h2>
				<div class="login-wrap">
					<input type="text" class="form-control" placeholder="工号" v-model="jobNumber">
					<input type="password" class="form-control" placeholder="密码" v-model="password">
					<button type="button" class="btn btn-primary block full-width m-b" @click="login">登录</button>
				</div>

			</form>

		</div>


	</body>
	<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/axios.js"></script>
	<script>
		var app =new Vue({
			el:".container",
			data:{
				jobNumber:"",
				password:""
			},
			methods:{
				login(){
					let data=new URLSearchParams();
					data.append("jobNumber",app.jobNumber);
					data.append("password",app.password);
					axios({
						method:"post",
						data:data,
						url:"/yly-api/admin/login"
					}).then(function (res) {
						console.log(res.data);
						if (res.data.code==200){
							if (res.data.status=="success"){
								alert("登录成功！");
								localStorage.token=res.data.token;
								location.href="index.html";
							}else if (res.data.status=="failed"){
								app.loginname="";
								app.password="";
								alert("密码错误！");
							}else {
								app.loginname="";
								app.password="";
								alert("用户名不存在");
							}
						}else if (res.data.code==500){
							location.href="500.html";
						}
					}).catch(function (error) {

					})
				}
			}
		})
	</script>
</html>
